#! /usr/bin/env python
# -*- coding: utf8 -*-

import random
import sys

if len(sys.argv) != 5:
    print "This program generates samples of a given size of a population (without replacement)"
    print "The output is in the format of python lists [ele1, ele2, ele3, ..., elen]"
    print "Usage: %s <sample size> <population size> <number of lists> <filename>" % (sys.argv[0], )
    sys.exit(0)


sample       = int(sys.argv[1])
population   = int(sys.argv[2])
list_ammount = int(sys.argv[3])

samples = random.sample(xrange(population), sample * list_ammount)

fp = open(sys.argv[4], "w")
for i in xrange(list_ammount):
    fp.write("%s\n" % (samples[i*sample : (i + 1) * sample],))
fp.close()
